package features;

import javax.swing.tree.DefaultMutableTreeNode;

import CAD.MainFrame;
import operationSolids.CompoundSolid;
import operationSolids.OperationBlock;

public class LinearProfile extends Feature{
	public double d1 =0;
	public double d2 = 0;
	public double depth= 0;
	public double angle=0;
	
	public LinearProfile(int type, Feature Mae,
			double d1,double d2,
			double positionX, double positionY,double positionZ, 
			double depth,String name, double angle,int face) {
		super(type, Mae,name);
		this.d1= d1;
		this.d2= d2;
		this.depth= depth;
		this.angle=angle;
		feature = new OperationBlock("",d2,(float) this.depth,d1);
		feature.rotate(0, angle);
		create(positionX, positionY, positionZ, face);
		MainFrame.features.add(this);
		MainFrame.refreshJTree();
	}

	@Override
	void translate() {
		feature.translate(placement.getX(), placement.getZ() - depth/2,placement.getY() );
		switch (MainFrame.Face) {
		case MainFrame.BACKFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.length/2,MainFrame.block.height/2);
			break;
		case MainFrame.FRONTFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.length/2,MainFrame.block.height/2);
			break;
		case MainFrame.EASTFACE:
			feature.translate(-MainFrame.block.length/2,MainFrame.block.width/2,MainFrame.block.height/2 );
			break;
		case MainFrame.WESTFACE:
			feature.translate(-MainFrame.block.length/2,MainFrame.block.width/2,MainFrame.block.height/2 );
			break;
		case MainFrame.LOWERFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.height/2,MainFrame.block.length/2);
			break;
		case MainFrame.TOPFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.height/2,MainFrame.block.length/2);
			break;

		default:
			System.out.println("erro");
			break;
		}
	}

	@Override
	void compound() {
		MainFrame.block  = new Block ("comp",CompoundSolid.DIFFERENCE,MainFrame.block,feature);
	}

	@Override
	public void drawNode(DefaultMutableTreeNode node) {
		node.add(
				new DefaultMutableTreeNode(
				"D1:"+d1+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"D2:"+d2+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"D1:"+d1+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"Depth:"+depth+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"Angle:"+angle+"mm")
				);
	}
	
}
